home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_400
/
422_04
/
monitor.asm
< prev
next >
Wrap
Assembly Source File
|
1994-02-14
|
20KB
|
646 lines
TITLE 8080/8085 SYSTEM MONITOR
****************************************************************
* 8080/8085 SYSTEM MONITOR *
*--------------------------------------------------------------*
* COMMANDS: *
* B .................... ENTER RESIDENT BASIC INTERPRETER. *
* D .................... DOWNLOAD FROM TERMINAL PORT. *
* G <ADR> .............. GO (EXECUTE) AT ADDRESS. *
* L .................... LOAD MEMORY FROM TAPE. *
* M <ADR>,<ADR> ........ DISPLAY MEMORY IN HEXIDECIMAL. *
* R .................... REENTER RESIDENT BASIC. *
* S <ADR> [NN]-<BYT> ... SUBSTUTE INTO MEMORY. *
* T 'H' OR 'F' ......... TERMINAL EMULATION MODE. *
* U <WRD> .............. REINITIALIZE 8251 UART. *
* W <ADDR>,<ADDR> ...... WRITE MEMORY TO TAPE. *
****************************************************************
PAGE
*
* CONSTANTS AND EQUATES...
*
DEFIO EQU 3 DEFAULT I/O CONFIGURATION
KEYBRD EQU 0 KEYBOARD INPUT PORT
UCTL EQU 2 UART CONTROL/STATUS PORT
UDAT EQU 1 UART DATA PORT
VIDEO EQU $1000 VIDEO DISPLAY RAM ADDRESS
BUFF EQU $1400 INPUT BUFFER
IOCON EQU BUFF+$FF I/O CONFIGURATION
USROUT EQU IOCON-2 USER OUTPUT ROUTINE VECTOR
CURSOR EQU USROUT-2 CURRENT CURSOR POSITION
LSTCHR EQU CURSOR-1 CHARACTER UNDER CURSOR
STACK EQU LSTCHR SYSTEM STACK
BASIC EQU $400 ADDRESS OF RESIDENT BASIC INTERPRETER
RENTRY EQU BASIC+$A3 ADDRESS TO REENTER BASIC
PAGE
*
* START OF MONITOR, FIRST INITIALIZE THE HARDWARE
*
START LXI SP,STACK INITALIZE STACK
LXI H,0 SET USRIO TO ZERO...
SHLD USROUT TO INDICATE IT HASN'T BEEN SET
MVI A,DEFIO DEFAULT I/O CONFIGURATION
STA IOCON SET I/O CONFIGURATION
LXI H,$7A37 USART 7 BITS, NO PARITY, HIGH-SPEED
CALL SETURT INITIALIZE 8251
MVI A,$0C CLEAR SCREEN CHARACTER
CALL OUT DISPLAY
JMP PRNT PROMPT FOR COMMAND
* GETS DOUBLE VALUE FOR HL, DE
DGET CALL AGET GET FIRST ADDRESS
XCHG SWAP
MVI A,',' GET SEPERATOR CHARACTER
CALL OUT DISPLAY
* GETS TWO BYTE VALUE FOR H-L
AGET CALL GETHL GET HEX VALUE
RC RETURN IF OK
* INDICATE ERROR WITH '?' ON CONSOLE
ERROR MVI A,'?' ERROR MESSAGE
CALL OUT DISPLAY IT
* RECOVER FROM ERROR, RESET STACK, SHUT TAPE OFF
ABORT LXI SP,STACK FIX UP STACK
CALL TOFF SHUT OFF TAPE
CALL NL NEW LINE ON TERMINAL
* WAIT FOR COMMAND
PRNT MVI A,'*' PROMPT MESSAGE
CALL OUT DISPLAY
CALL IN GET CHARACTER FROM TERMINAL
CALL OUT ECHO
MOV B,A SAVE FOR COMPARISON
CALL SPACE DISPLAY SEPARATER
LXI H,CTAB POINT TO COMMAND TABLE
CLOOK MOV A,M GET CMD FROM TABLE
INX H POINT TO NEXT
ANA A TEST FOR END IF TABLE
JZ ERROR IF SO, INDICATE SO
MOV E,M GET LOW ADDRESS
INX H POINT TO HIGH
MOV D,M GET HIGH ADDRESS
INX H POINT TO NEXT
CMP B TEST FOR ENTERED COMMAND
JNZ CLOOK KEEP LOOKING TILL WE FIND
LXI H,ABORT ADDRESS TO RETURN TO
PUSH H SAVE RETURN ADDRESS
XCHG SWAP TO H-L
PCHL EXECUTE USER CODE
CTAB DB 'B' BASIC COMMAND?
DW BASIC ADDRESS OF BASIC INTERPRETER
DB 'R' TEST FOR 'REENTER'
DW RENTRY REENTER BASIC
DB 'D' TEST FOR DOWNLOAD
DW DNLD PERFORM DOWNLOAD
DB 'L' TEST FOR 'LOAD'
DW LOAD LOAD FROM TAPE
DB 'U' TEST FOR 'UART'
DW UART SET UP UART
DB 'G' TEST FOR 'GO'
DW GO GO EXECUTE
DB 'S' TEST FOR 'SUB'
DW SUBST SUBST. MEMORY
DB 'W' TEST FOR 'WRITE'
DW DUMP DUMP SOME OUT
DB 'M' TEST FOR 'M'
DW MEMRY MEMORY CODE
DB 'T' TERMINAL MODE???
DW TMODE IF SO, ENTER TERMINAL
DB 0 INDICATE END OF TABLE
*
* DISPLAY MEMORY COMMAND
*
MEMRY CALL DGET GET ADDRESSES
XCHG SWAP BACK
MLOOP CALL NL START A NEW LINE
CALL HLOUT DISPLAY ADDRESS
ML1 CALL SPACE DISPLAY SPACE
MOV A,M GET CONTENTS
CALL HOUT DISPLAY HEX
CALL CHLDE TEST FOR END
RNC IF SO, STOP
INX H NEXT BYTE
MOV A,L GET LOW ADDRESS
ANI $0F TEST FOR END OF LINE
JNZ ML1 IF NOT, KEEP GOING
CALL CTRLC TEST FOR USER ABORT
JNZ MLOOP IF NOT, KEEP DISPLAYING
RET
*
* GO COMMAND
*
GO CALL AGET GET ADDRESS TO 'GO' AT
PCHL SET PROGRAM COUNTER
*
* SUBSTUTUTE COMMAND
*
SUBST CALL AGET GET ADDRESS
SUB0 CALL NL START ON A NEW LINE
CALL HLOUT DISPLAY ADDRESS
MVI D,8 EIGHT BYTES/LINE
SUB1 CALL SPACE SKIP A SPACE
MOV A,M GET CONTENTS
CALL HOUT DISPLAY
MVI A,'-' PROMPT WITH '-'
CALL OUT DISPLAY
CALL GETBYT GET BYTE
JC SUB3 IF OK, SUBSTUTE
CPI $0D TEST FOR ABORT
RZ IF SO, BACK FOR COMMAND
CALL SPACE OTHERWISE, PRINT.
CALL SPACE TWO SPACES (SAME SPACE AS HEX DIGITS)
MOV A,M GET OLD BYTE BACK
SUB3 MOV M,A REPLACE MEMORY CONTENTS
SNXT INX H NEXT LOCATION IN MEMORY
DCR D REDUCE COUNT OF BYTES/LINE
JNZ SUB1 IF OK, STAY ON SAME LINE
JMP SUB0 OTHERWISE GO TO NEW LINE
*
* DUMP COMMAND
*
DUMP CALL DGET GET ADDRESSES
* DE=START ADDRESS, H-L=END ADDRESS
DUMP1 INX H ADVANCE BY ONE BYTE
MOV A,H TEST FOR SPECIAL CASE
ANA A IF ZERO PAGE
JZ LBOT IF SO, SPECIAL CASE
PUSH H SAVE ENDING VALUE
LXI B,$FF01 GET VALUE TO SUBTRACT
DAD B SUBTRACT FROM ENDING ADDRESS
XCHG SWAP BACK
CALL TON START TAPE DRIVE
DRECL CALL CHLDE SEE IF WE HAVE FINISHED YET
JNC LREC IF SO, LAST RECORD
MVI A,$FF OTHERWISE, RECORD LENGTH IS 255
CALL DUMPR DUMP OUT RECORD
JMP DRECL KEEP GOING TILL LAST RECORD
LREC POP D GET ADDRES BACK
XCHG SWAP
LBOT PUSH D GET ADDRESS BACK
MOV A,D TAKE.
CMA TWO'S.
MOV D,A COMPLEMENT.
MOV A,E SO WE CAN.
CMA SUBTRACT.
MOV E,A FROM THE
INX D ORIGIONAL ADDRESS
DAD D SUBTRACT
MOV A,L GET LENGTH
POP H GET ADDRESS BACK
CALL DUMPR DUMP LAST RECORD
SUB A END OF FILE INDICATOR
*
* DUMPS A RECORD IN INTEL HEX FORMAT
*
DUMPR MOV B,A SAVE LENGTH IN B
MVI A,4 SET FOR UART OUTPUT
STA IOCON SET I/O CONF
CALL NL DISPLAY LF CR TO TAPE
MVI A,':' START OF RECORD
CALL OUT WRITE TO TABE
MOV A,B GET LENGTH
MOV C,A START CHECKSUM
CALL HOUT WRITE LENGTH TO TAPE
MOV A,B GET LENGTH BACK
ANA A TEST FOR END OF FILE
JZ ENDMP IF SO, STOP
CALL HLOUT WRITE ADDRESS TO TAPE
MOV A,C GET CHECKSUM
ADD H ADD HIGH ADDRESS
ADD L ADD LOW ADDRESS
MOV C,A RESAVE CHECKSUM
SUB A DATA TYPE ZERO
CALL HOUT WRITE TO TAPE
MHEX MOV A,M GET BYTE OF DATA TO DUMP
CALL HOUT WRITE TO TAPE
MOV A,M GET DATA BACK
ADD C ADD TO CHECKSUM
MOV C,A RESAVE CHECKSUM
INX H NEXT MEMORY LOCATION
DCR B REDUCE LENGTH
JNZ MHEX IF NOT END, KEEP DUMPING
CMA INVERT TO MAKE.
INR A TWO'S COMPLEMENT CHECKSUM
CALL HOUT WRITE CHECKSUM TO TAPE
ENDMP MVI A,DEFIO GET DEFAULT I/O CONF
STA IOCON RESET I/O CONFIGURATION
RET
*
* COMPARE'S H-L WITH D-E
*
CHLDE MOV A,H GET HIGH IF HL
CMP D TEST WITH HIGH OF DE
RNZ IF NOT SAME, PROBLEM SOLVED
MOV A,L GET LOW HL
CMP E SET FLAGS FOR COMPARE WITH LOW DE
RET
* DISPLAYS A SPACE ON THE TERMINAL
SPACE MVI A,' ' GET A SPACE
JMP OUT DISPLAY
*
* DISPLAYS 16 BIT VALUE OF H-L ON THE TERMINAL
*
HLOUT MOV A,H GET H
CALL HOUT DISPLAY H IN HEX
MOV A,L GET L
* DISPLYS 8 BIT VALUE OF ACC IN HEX
HOUT PUSH PSW SAVE LOW DIGIT
RRC MAKE HIGH.
RRC DIGIT.
RRC INTO.
RRC LOW DIGIT.
CALL HXOUT PRINT HIGH DIGIT
POP PSW GET LOW DIGIT BACK
HXOUT ANI $0F GET RID OF EXCESS BAGGAGE
ADI $30 CONVERT TO ASCII NUMBER
CPI $3A TEST FOR ALPHA CHARACTER
JC OUT IF NOT, WE ARE OK
ADI 7 CONVERT TO CHARACTER
*
* OUTPUT ROUTINE, DISPLAYS CONTENTS OF ACC ON ALL ENABLED
* OUTPUT DEVICES
*
OUT PUSH B SAVE B-C PAIR
PUSH D SAVE D-E PAIR
PUSH H SAVE H-L PAIR
MOV B,A SAVE CHARACTER IN B
LDA IOCON GET I/O CONFIGURATION
MOV C,A SAVE IN C
ANI $40 TEST FOR OUTPUT DISABLED
JNZ OEXIT IF SO, ABORT
MOV A,C GET CONFIGURATION BACK
ANI 2 TEST FOR VIDEO DISPLAY ENABLED
JZ OURT NO, TRY UART
* OUTPUT TO VIDEO DISPLAY
OVID LHLD CURSOR GET CURSOR POSITION
LDA LSTCHR GET CHARACTER UNDER CURSOR
MOV M,A REPLACE CURSOR
MOV A,B GET CHARACTER TO PRINT
CPI 13 TEST FOR CR
JZ CR ADVANCE TO NEXT LINE
CPI 10